// 双十一假数据
var list_1 = [
    s = [{
        src: "./image/01.png"
    }, {
        src: "./image/02.png"
    }, {
        src: "./image/03.png"
    }, {
        src: "./image/04.png"
    }],
    s1 = [{
        src: "./image/fifth1.png"
    }, {
        src: "./image/fifth2.png"
    }, {
        src: "./image/fifth3.png"
    }, {
        src: "./image/fifth4.png"
    }, ]
]
$.each(s, function (index, val) {
    $('.double:eq(0)').append(`
    <li>
    <img src="${val.src}">
</li>`)
})
$.each(s1, function (index, val) {
    $('.double:eq(1)').append(`
    <li>
    <img src="${val.src}">
</li>`)
})
// 点击双十一隐藏显示变色
$(".earth a:eq(0)").click(function () {
    $(this).css('font-size', "0.32rem")
    $(this).css('color', "#ff6040")
    $(".double:eq(0)").show()
    $(".double:eq(1)").hide();
    $(".earth a:eq(1)").css('font-size', "0.28rem")
    $(".earth a:eq(1)").css('color', "#999")
})
// 畅销全球
$(".earth a:eq(1)").click(function () {
    $(".earth a:eq(0)").css('font-size', "0.28rem")
    $(".earth a:eq(0)").css('color', "#999")
    $(this).css('font-size', "0.32rem")
    $(this).css('color', "#ff6040")
    $(".double:eq(1)").show()
    $(".double:eq(0)").hide()
})
// 热门推荐的假数据
var list_2 = [
    s2 = [{
        src: "./image/p1.webp",
        title: "小米10",
        price: "现价格：￥3999",
        del: "原价格：￥3999",
        shop: "立即抢购"
    }, {
        src: "./image/p2.webp",
        title: "华为MateBook13",
        price: "现价格：￥4299",
        del: "原价格：￥4597",
        shop: "立即抢购"
    }],
    s3 = [{
        src: "./image/p3.webp",
        title: "小米10",
        price: "现价格：￥3999",
        del: "原价格：￥3999",
        shop: "立即抢购"
    }, {
        src: "./image/p4.webp",
        title: "华为MateBook13",
        price: "现价格：￥4299",
        del: "原价格：￥4597",
        shop: "立即抢购"
    }],
    s4 = [{
        src: "./image/p5.webp",
        title: "小米10",
        price: "现价格：￥3999",
        del: "原价格：￥3999",
        shop: "立即抢购"
    }, {
        src: "./image/p6.webp",
        title: "华为MateBook13",
        price: "现价格：￥4299",
        del: "原价格：￥4597",
        shop: "立即抢购"
    }],
]
// 热门推荐
$.each(s2, function (index, val) {
    $('#phone:eq(0)').append(`
    <li>
    <img src="${val.src}">
    <h2>${val.title}</h2>
    <p>${val.price}</p>
    <s>${val.del}</s>
    <a href="JavaScript:;">${val.shop}</a>
</li>`)
})
// 点击热门其他的隐藏
$("#hotdoor li:eq(0)").click(function(){
    $(this).css('background', "#d46a13").siblings().css("background","#fff");
    $(this).css('color', "#fff").siblings().css("color","#ff6044");
    $("#phone").show();
    $("#phone1").hide();
    $("#phone2").hide();
})
// 上新
$.each(s3, function (index, val) {
    $('#phone1').append(`
    <li>
    <img src="${val.src}">
    <h2>${val.title}</h2>
    <p>${val.price}</p>
    <s>${val.del}</s>
    <a href="JavaScript:;">${val.shop}</a>
</li>`)
})
// 点击热门其他的隐藏
$("#hotdoor li:eq(1)").click(function(){
    $(this).css('color', "#fff").siblings().css("color","#ff6044");
    $(this).css('background', "#d46a13").siblings().css("background","#fff");
    $("#phone").hide();
    $("#phone1").show();
    $("#phone2").hide();
})
// 所有
$.each(s4, function (index, val) {
    $('#phone2').append(`
    <li>
    <img src="${val.src}">
    <h2>${val.title}</h2>
    <p>${val.price}</p>
    <s>${val.del}</s>
    <a href="JavaScript:;">${val.shop}</a>
</li>`)
})
// 点击热门其他的隐藏
$("#hotdoor li:eq(2)").click(function(){
    $(this).css('background', "#d46a13").siblings().css("background","#fff");
    $(this).css('color', "#fff").siblings().css("color","#ff6044");
    $("#phone").hide();
    $("#phone1").hide();
    $("#phone2").show();
})

// 倒计时
over()
setInterval(over, 1000)
function over() {
    var otimer = document.getElementsByClassName("timer")[0];
    var op = otimer.getElementsByTagName("p");
    // 当前时间
    var odate = new Date;
    // 未来时间
    var futuretime = new Date("2022,4,15,00:00:00");
    // 倒计时原理（时间差）= 未来时间-现在时间
    var time = parseInt((futuretime - odate) / 1000); //秒
    var day = parseInt(time / 86400); //天
    var hour = parseInt(time % 86400 / 3600) //时
    var min = parseInt(time % 86400 % 3600 / 60) //分
    var miao = time % 60
    op[0].innerText = le(day)
    op[1].innerText = le(hour)
    op[2].innerText = le(min)
    op[3].innerText = le(miao)
}   

function le(num) {
    return num < 10 ? "0" + num : num
}